package com.med.meddataintegrator.admin.controller;

import com.med.meddataintegrator.common.pojo.dto.hospitalization.HospitalizationAddParam;
import com.med.meddataintegrator.common.pojo.dto.hospitalization.HospitalizationQuery;
import com.med.meddataintegrator.common.pojo.dto.hospitalization.HospitalizationUpdateParam;
import com.med.meddataintegrator.common.pojo.vo.hospitalization.HospitalizationVo;
import com.med.meddataintegrator.admin.service.HospitalizationService;
import com.med.meddataintegrator.admin.base.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("admin/hospitalization")
public class HospitalizationController {
    @Autowired
    HospitalizationService hospitalizationService;

    @GetMapping("select")
    public JsonResult select(HospitalizationQuery hospitalizationQuery){
        log.debug("查询入院信息 {}", hospitalizationQuery);
        List<HospitalizationVo> list = hospitalizationService.select(hospitalizationQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("add")
    public JsonResult add(@RequestBody HospitalizationAddParam hospitalizationAddParam){
        log.debug("添加入院信息", hospitalizationAddParam);
        hospitalizationService.add(hospitalizationAddParam);
        return JsonResult.ok();
    }
    @PostMapping("update")
    public JsonResult update(@RequestBody HospitalizationUpdateParam hospitalizationUpdateParam){
        log.debug("修改入院信息", hospitalizationUpdateParam);
        hospitalizationService.update(hospitalizationUpdateParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult delete(@PathVariable Integer id){
        log.debug("删除入院信息", id);
        hospitalizationService.delete(id);
        return JsonResult.ok();
    }
}
